/*
 * 文件名：AdInfoServiceImpl.java
 * 版权：Copyright by www.huawei.com
 * 描述：
 * 修改人：lilan
 * 修改时间：2016年4月20日
 * 跟踪单号：
 * 修改单号：
 * 修改内容：
 */

package com.zcsy.manage.service.mall.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zcsy.manage.model.mall.AdInfo;
import com.zcsy.manage.persistence.mall.AdInfoDao;
import com.zcsy.manage.service.mall.IAdInfoService;

/**
 * 
 * @Title: AdInfoServiceImpl.java
 * @Package： com.zcsy.manage.service.mall.impl 
 * @Description: 广告位信息service层接口实现类
 *
 * @author lilan 1063972142@qq.com
 * @Copyright: 2015 武汉恒数利通信息技术有限公司 All rights reserved.
 * @date 2016年4月20日
 * @version 1.0
 * @see JDK1.7.0_75
 * @since
 */
@Service
public class AdInfoServiceImpl implements IAdInfoService{

	@Autowired
	private AdInfoDao adInfoDao;

	@Override
	public int insert(AdInfo adInfo) {
		return adInfoDao.insert(adInfo);
	}

	@Override
	public int update(AdInfo adInfo) {
		AdInfo oldInfo = adInfoDao.selectByPrimaryKey(adInfo.getId());
		
		oldInfo.setTitle(adInfo.getTitle());
		oldInfo.setAdCategoryId(adInfo.getAdCategoryId());
		oldInfo.setBeginTime(adInfo.getBeginTime());
		oldInfo.setEndTime(adInfo.getEndTime());
		oldInfo.setObjType(adInfo.getObjType());
		oldInfo.setObjId(adInfo.getObjId());
		oldInfo.setUrl(adInfo.getUrl());
		oldInfo.setRemark(adInfo.getRemark());
		oldInfo.setSort(adInfo.getSort());
		oldInfo.setImg(adInfo.getImg());
		oldInfo.setState(adInfo.getState());
		oldInfo.setUserAccount(adInfo.getUserAccount());
		oldInfo.setUserAccountType(adInfo.getUserAccountType());
		oldInfo.setUpdateTime(adInfo.getUpdateTime());
		
		return adInfoDao.update(oldInfo);
	}

	@Override
	public int deleteByPrimaryKey(String id) {
		return adInfoDao.deleteByPrimaryKey(id);
	}

	@Override
	public List<AdInfo> selectByKeyword(AdInfo adInfo) {
		return adInfoDao.selectByKeyword(adInfo);
	}

	@Override
	public AdInfo selectByPrimaryKey(String id) {
		return adInfoDao.selectByPrimaryKey(id);
	}

	@Override
	public List<AdInfo> selectApplyByKeyword(AdInfo adInfo) {
		return adInfoDao.selectApplyByKeyword(adInfo);
	}

	@Override
	public List<AdInfo> selectAdinfoByKeyword(AdInfo adInfo) {
		return adInfoDao.selectAdinfoByKeyword(adInfo);
	}

	@Override
	public int updateSort(AdInfo record) {
		return adInfoDao.updateSort(record);
	}

	@Override
	public List<AdInfo> selectByAdCategoryId(String adCategoryId,String cellId) {
	    Map<String,String> map = new HashMap<String,String>();
	    map.put("adCategoryId", adCategoryId);
	    map.put("cellId", cellId);
		return adInfoDao.selectByAdCategoryId(map);
	}
	
	@Override
	public List<AdInfo> selectBannerByAdCategoryId(String adCategoryId) {
	    return adInfoDao.selectBannerByAdCategoryId(adCategoryId);
	}

}
